package com.lei.sqlGoodsJsp.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.lei.sqlGoodsJsp.constant.UserConstant;

public class CountServlet extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		 PrintWriter out=response.getWriter();
		HttpSession session=request.getSession();
		System.out.println(session.getId());
		Integer count=(Integer)session.getAttribute("count");
		if(count==null) {
			count=1;
		}else {
			count++;
		}
		session.setAttribute(UserConstant.USER_INFO, count);
		out.println("第"+count+"次访问");
		out.close();
	}

}
